package lab02.test24;

import java.util.Calendar;
import java.util.Date;
import java.util.Scanner;

/**
 * Created by V555 on 2017/11/1.
 */
public class Test {
    public static void main(String[] args) {
        System.out.print("输入一个日期：");
        Scanner scanner=new Scanner(System.in);
        Calendar calendar=Calendar.getInstance();
        String s=scanner.nextLine();
        String year=s.substring(0,4);
        String month=s.substring(4,6);
        String day=s.substring(6);
        calendar.set(Integer.parseInt(year),Integer.parseInt(month),Integer.parseInt(day));
        Date dateone=calendar.getTime();
        System.out.print("输入第二个日期：");
        s=scanner.nextLine();
        year=s.substring(0,4);
        month=s.substring(4,6);
        day=s.substring(6);
        calendar.set(Integer.parseInt(year),Integer.parseInt(month),Integer.parseInt(day));
        Date datetwo=calendar.getTime();
        long countDay=(dateone.getTime()-datetwo.getTime())/(24*60*60*1000);
        System.out.print("两个日期相差的天数：");
        System.out.println(countDay);




    }
}
